﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Infragistics.Win.UltraWinTree;

namespace WindowsFormsApplication283
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();


            // Declare nodes
            UltraTreeNode nodeA;
            UltraTreeNode nodeB;

            // Add two nodes to the WinTree
            nodeA = this.ultraTree1.Nodes.Add("nodeA", "NodeA");
            nodeB = this.ultraTree1.Nodes.Add("nodeB", "NodeB");

            // Expand the newly added node
            nodeA.Expanded = true;

            // Add a child node to Node A
            nodeA.Nodes.Add("childNodeofA", "ChildNodeA1");

            // Add Node C to WinTree
            this.ultraTree1.Nodes.Add("nodeC", "NodeC");

            // Get a reference to Node C using its key
            UltraTreeNode nodeC = this.ultraTree1.GetNodeByKey("nodeC");
            
            // Add a child node to NodeC
            nodeC.Nodes.Add("childNodeofC", "ChildNodeC1");

            // Remove NodeB
            this.ultraTree1.Nodes.Remove(nodeB);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            UltraTreeNode nodeC = this.ultraTree1.GetNodeByKey("nodeC");
            nodeC.Expanded = true;
            // Add a child node to NodeC
            nodeC.Nodes.Add(textBox1.Text, textBox1.Text);

            
        }
    }
}
